//
//  ZHViewController.m
//  ZHS_UCDemo
//
//  Created by Emrys on 2016/11/7.
//  Copyright © 2016年 Emrys. All rights reserved.
//

#import "ZHViewController.h"

#import "MBProgressHUD.h"

static const CGFloat kZHHudMargin = 5.f;
static const CGFloat kZHHudToBottomOffset_Y = 80;

@interface ZHViewController ()

@end

@implementation ZHViewController

+ (instancetype)viewControllerFromStoryboardWithClassName:(NSString *)className {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:className bundle:nil];
    
    if (storyboard.instantiateInitialViewController) {
        return [storyboard instantiateInitialViewController];
    }
    
    return nil;

}

+ (instancetype)viewControllerFromStoryboard {
    
    return [self viewControllerFromStoryboardWithClassName:NSStringFromClass([self class])];
}

+ (instancetype)viewController {
    
    return [self viewControllerFromClassName:NSStringFromClass(self)];
}

+ (instancetype)viewControllerFromClassName:(NSString *)className {
    
    ZHViewController *viewController = [[NSClassFromString(className) alloc] init];
    
    if (viewController) {
        return viewController;
    }
    
    return nil;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark -
#pragma mark - HUD
-(void)showTextHint:(NSString *)message{
    
    UIView *groundView = (nil == self.navigationController) ? self.view : self.navigationController.view;
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:groundView animated:YES];
    
    // Set the text mode to show only text.
    hud.mode = MBProgressHUDModeText;
    
    hud.label.text = message;
    hud.label.textColor = [UIColor whiteColor];
    hud.label.font = [UIFont systemFontOfSize:15];
    
    hud.margin = kZHHudMargin;
    
    // Move to bottm center.
    hud.offset = CGPointMake(0.f, (kScreenHeight/2 - kZHHudToBottomOffset_Y));
    
    hud.bezelView.color = [UIColor blackColor];
    
    [hud hideAnimated:YES afterDelay:3.f];
}

@end
